using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
    public class tbBinhLuanBUS
    {
        public static void Insert(tbBinhLuan binhluan)
        {
            tbBinhLuanDAL blDAL = new tbBinhLuanDAL();
            blDAL.Insert(binhluan);
        }
        public static void Update(tbBinhLuan binhluan)
        {
            tbBinhLuanDAL blDAl = new tbBinhLuanDAL();
            blDAl.Update(binhluan);
        }
        public static void Delete(int iD)
        {
            tbBinhLuanDAL blDAl = new tbBinhLuanDAL();
            blDAl.Delete(iD);
        }
        public static tbBinhLuanCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbBinhLuanDAL blDAL = new tbBinhLuanDAL();
            return blDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbBinhLuanCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbBinhLuanDAL blDAL = new tbBinhLuanDAL();
            return blDAL.Get(cri.Criter, 0, 0, tbDatHangColumns.stt.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbBinhLuan GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDatHangColumns.stt.ToString(), Condition.EQUAL, iD);
            tbBinhLuanDAL blDAL = new tbBinhLuanDAL();
            tbBinhLuanCollection blCollection = blDAL.Get(cri.Criter, 0, 0, tbDatHangColumns.stt.ToString(), OrderDirection.ASC.ToString(), out total);
            if (blCollection.Count > 0)
                return blCollection[0];
            return null;
        }
        public static tbBinhLuanCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbBinhLuanDAL blDAL = new tbBinhLuanDAL();
            return blDAL.Get(cri.Criter, 1, number, tbDatHangColumns.stt.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbBinhLuanCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbBinhLuanDAL blDAL = new tbBinhLuanDAL();
            return blDAL.Get(cri.Criter, 1, number, tbDatHangColumns.stt.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
